﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Master_OakMasterPage : System.Web.UI.MasterPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
        string realIID = HttpContext.Current.User.Identity.Name.Substring(3).ToLower();
        if (realIID.Equals("tomsenhong") || realIID.Equals("jasonzhan") || realIID.Equals("xiaoboli"))
            this.panelDemo.Visible = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        string curIID = HttpContext.Current.User.Identity.Name.Substring(3).ToLower();

        if (string.IsNullOrEmpty(curIID))
            Response.Redirect("~/");

        if (!IsPostBack)
            SetLable();
    }

    protected void SetLable()
    {
        this.YearLabel.Text = DateTime.Now.Year.ToString("0000");
        this.YearLabel2.Text = DateTime.Now.Year.ToString("0000");
    }

    protected void btnDemo_Click(object sender, EventArgs e)
    {
        if (this.btnDemo.CommandName.Equals("Login"))
        {
            string iid = this.txtDemo.Text.Trim();
            if (string.IsNullOrEmpty(iid))
                return;

            HttpContext.Current.Session["Demo_iid"] = iid;
            Response.Redirect("~/Default.aspx");

            this.btnDemo.Text = "Restore";
            this.btnDemo.CommandName = "Restore";
        }
        else if (this.btnDemo.CommandName.Equals("Restore"))
        {
            HttpContext.Current.Session["Demo_iid"] = null;
            Response.Redirect("~/Default.aspx");

            this.btnDemo.Text = "Log in";
            this.btnDemo.CommandName = "Login";
        }
    }
}
